package com.nineclock.common.minIo;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * MinIO客户端初始配置类
 */
@Configuration
@EnableConfigurationProperties(MinIOConfigProperties.class) // 开启属性配置
public class MinIOConfiguration {
    @Autowired
    private MinIOConfigProperties configProperties;

    @Bean
    public MinioClient createMinioClient(){
        return MinioClient.builder()
                .credentials(configProperties.getAccessKey(),configProperties.getSecretKey())
                .endpoint(configProperties.getEndpoint()).build();
    }
}